package vn.mobiistar.videoapp.util;

import java.io.File;

import vn.mobiistar.videoapp.R;

import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.utils.StorageUtils;

import android.app.Application;
import android.location.Location;

public class GlobalApplication extends Application {
	private Location userLocation;
	private static GlobalApplication _application;
	public static DisplayImageOptions options;
	private ImageLoaderConfiguration config;
	 
	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		super.onCreate();
		TypefaceUtil.overrideFont(getApplicationContext(), "SERIF",
				"fonts/UTM_Nokia_Standard.ttf");
		initImageLoader();
	}

	public void initImageLoader() {
		File cacheDir = StorageUtils.getCacheDirectory(this);
		config = new ImageLoaderConfiguration.Builder(this)
				.diskCache(new UnlimitedDiscCache(cacheDir))
				.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
				.writeDebugLogs().build();

		options = new DisplayImageOptions.Builder()
				.showImageOnLoading(R.drawable.ic_loading)
				.showImageForEmptyUri(R.drawable.ic_empty)
				.showImageOnFail(R.drawable.ic_error).cacheInMemory(true)
				.cacheOnDisk(true).considerExifParams(true)
				.displayer(new SimpleBitmapDisplayer()).build();

		ImageLoader.getInstance().init(config);
	}

	public static GlobalApplication _() {
		return _application;
	}

	public GlobalApplication() {
		_application = this;

	}

}
